package cn.edu.nenu.contract.dto;
/**
 * @author Kaginux
 * @version 6:57:17 PM Apr 17, 2011
 */
public class ITADate {
	// TODO exception when the setter obtain an unreasonable argument
	private int week;
	private int year;

	private boolean checkDate() {
		if (week < 1 || week > 51)
			return false;
		if (year < 2011 || year > 2099)
			return false;
		return true;
	}
	public ITADate(int week, int year) {
		super();
		this.week = week;
		this.year = year;
		if (!checkDate()) {
			// TODO exception
		}
	}

	public ITADate(int yearweek) {
		this.week = yearweek % 100;
		this.year = yearweek / 100;
	}

	public ITADate(){//Default
		this.week = 1;
		this.year = 2011;
	}
	
	public int getYearWeek(){
		return year*100+week;
	}
	public int getWeek() {
		return week;
	}

	public void setWeek(int week) {
		this.week = week;
		if (!checkDate()) {
			// TODO exception
		}
	}

	public int getYear() {
		return year;
	}

	public void setYear(int year) {
		this.year = year;
		if (!checkDate()) {
			// TODO exception
		}
	}
	@Override
	public String toString() {
		return "DateDTO [week=" + week + ", year=" + year + "]";
	}
}
